package cn.cdeden.system.controller.system;


import cn.cdeden.common.core.domain.R;
import cn.cdeden.common.core.utils.page.TableDataInfo;
import cn.cdeden.knowledge.api.domain.RemoteEnterpriseTemplateTreeService;
import cn.cdeden.knowledge.api.domain.page.PageQuery;
import cn.cdeden.knowledge.api.domain.vo.EnterpriseTemplateTreeVo;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Set;

@Validated
@RequiredArgsConstructor
@RestController
//@Api(tags = "企业知识库模板管理")
@RequestMapping("/api/enterpriseTemplate")
public class RemoteEnterpriseTemplateTreeController {

    @DubboReference(check = false)
    private final RemoteEnterpriseTemplateTreeService remoteEnterpriseTemplateTreeService;

    @GetMapping
//    @Log("查询所有文件夹模板")
//    @ApiOperation("查询所有文件夹模板")
    public R<TableDataInfo<EnterpriseTemplateTreeVo>> query(String realName, PageQuery pageQuery){
        TableDataInfo<EnterpriseTemplateTreeVo> info = remoteEnterpriseTemplateTreeService.queryAll(realName,pageQuery);
        return R.ok(info);
    }

    @GetMapping("/selectNext")
//    @Log("查询模板下所有文件夹")
//    @ApiOperation("查询模板下所有文件夹")
    public R<EnterpriseTemplateTreeVo> Folder(Long id){
        return R.ok(remoteEnterpriseTemplateTreeService.selectNext(id));
    }

    @DeleteMapping
//    @Log("删除模板")
//    @ApiOperation("删除模板")
    public R delete(@RequestBody Set<Long> ids) {
        return R.ok(remoteEnterpriseTemplateTreeService.deleteByTemplateId(ids));
    }
}
